#pragma once

#include "Sprite.h"
#include "Weapon.h"
#include "HealthPack.h"

enum PlayerType {HUMAN,CIVILIAN,ENEMY,BOSS};

class Player
{
protected:
	SpriteObject *body;
	SpriteObject *brain;
	Weapon *weapon;
public:
	Player(){}
	Player(Vector2 pos);
	~Player();
	void handlePlatformCollision(GameObject* p, float dt);
	virtual void handlePlayerCollision(Player* p, float dt);
	virtual bool handleProjectileCollision(Projectile* p);
	virtual bool handleHealthPackCollsion(HealthPack* hp);
	virtual void update(const float &timestep);
	void render();
	Vector2 getPos() { return body->getPos(); }
	virtual void determineAction(std::vector<Platform*> &platforms,
															 std::vector<Player*> &npcs,
															 Player* player,
															 float timestep) { }
	bool playerCanSee;
	WeaponType type;
	SpriteObject *getBody() { return body; }
	SpriteObject *getBrain() { return brain; }
	bool controlsPerson;
	PlayerType playertype;
	void InitializeControls(Vector2 pos);
	Vector2 previousPosition;
	float jumpVelocity;
	float walkVelocity;
	bool canJumpOnPlatform(GameObject* p);
	Player* jumpTarget;

	float attackTime;

	bool dead() { return body->dead(); }
	bool gone; //player disappears / taken over

	void setWeaponType(WeaponType type_);
	float timeToPerformAction;
	float timeElapsedPerformingAction;
	float timeSinceLastShot;
	float timeSinceLastDamage;
	struct Controls
	{
		bool left;
		bool right;
		bool up;
		bool down;
		bool jump;
		bool fire;
		bool personJump;
		Controls() : left(false), right(false), up(false), down(false), jump(false), fire(false), personJump(false){}
	} controls;

	Vector2 brainSlugPos();
	Vector2 weaponPos();
	void setExtrasInPosition();
	float distanceFrom(Player *p);
	virtual void jumpOn(Player* p);
	SpriteObject* jumpOff();
	std::vector<Projectile*> fireWeapon();
};